package com.typhoon.spring_shiro.utils.asserts;

import org.springframework.util.Assert;

import com.alibaba.druid.util.StringUtils;

/**
 * 断言工具类
 * 
 * @author Typhoon
 *
 */
public class AssertUtils extends Assert {
	
	/**
	 * assert the param cannot be null or length == 0
	 * @param param
	 * @param msg
	 */
	public static void notBlank(String param,String msg) {
		if(StringUtils.isEmpty(param)) {
			throw new IllegalArgumentException(StringUtils.isEmpty(msg) ? "[Assertion failed] - the param argument must be null" : msg);
		}
	}
	
	/**
	 * assert the param cannot be null or length == 0
	 * @param param
	 */
	public static void notBlank(String param) {
		notBlank(param, null);
	}
	
	
	/**
	 * these params can not be null
	 * @param msg
	 * @param objects
	 */
	public static void notNull(String msg,Object ... objects) {
		for(Object obj : objects) {
			if(null == obj) {
				throw new IllegalArgumentException(StringUtils.isEmpty(msg) ? "[Assertion failed] - the param argument must be null" : msg);
			}
		}
	}
	
	public static void notNull(Object ...objects) {
		notNull(null,objects);
	}

}
